﻿using System;
using System.Collections.Generic;
using System.Text;
using AgencyManagerSystem.Model;
using AgencyManagerSystem.Common;
using Dapper;
using System.Linq;

namespace AgencyManagerSystem.DataFetcher
{
    public class RoleUserFetcher : BaseFetcher<RoleUserModel>
    {
        public RoleUserFetcher() : base()
        {

        }
        public IList<RoleUserModel> ListByUser(int uid)
        {
            Condition[] conditions = new Condition[] { new Condition() { Key = "User", Op = "=", Value = uid } };
            var list = List(conditions);
            return list;
        }
        public IList<RoleUserModel> ListByDomain(int did)
        {
            Condition[] conditions = new Condition[] { new Condition() { Key = "Domain", Op = "=", Value = did } };
            var list = List(conditions);
            return list;
        }
        public IList<RoleUserModel> ListByUserDomain(int uid,int did)
        {
            Condition[] conditions = new Condition[] {
                new Condition() { Key = "User", Op = "=", Value = uid },
                new Condition() { Key = "Domain", Op = "=", Value = did }
            };
            var list = List(conditions);
            return list;
        }
        public IList<RoleUserModel> ListByRole(int rid)
        {
            Condition[] conditions = new Condition[] { new Condition() { Key = "Role", Op = "=", Value = rid } };
            var list = List(conditions);
            return list;
        }
    }
}
